package com.binyouwei.designpatterns.behavior.iterator;

/**
 * @author 宾有为
 * Created on 2024/7/15 18:59
 * Social homepage: https://blog.csdn.net/baidu_41616022
 * @desc 迭代器模式 - 允许顺序访问一个聚合对象中的元素，同时不暴露对象的内部表示。
 **/
public class IteratorMain {

    public static void main(String[] args) {
        IteratorConcreteCollection collection = new IteratorConcreteCollection();
        collection.addItem("First item");
        collection.addItem("Second item");

        Iterator iterator = collection.createIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
